﻿using System;
using vBridge.Design;
using vBridge.Design.Mvvm;

namespace vBridge.Dwm.Aero.Margins
{
    public class MarginsViewModel : ViewModelBase, IMargins
    {
        private readonly IMargins _margins;

        #region Model Fields

        public Int32 Left
        {
            get { return _margins.Left; }
            set
            {
                if (value == Left) return;
                OnPropertyChanging();
                _margins.Left = value;
                OnPropertyChanged();
            }
        }

        public Int32 Top
        {
            get { return _margins.Top; }
            set
            {
                if (value == Top) return;
                OnPropertyChanging();
                _margins.Top = value;
                OnPropertyChanged();
            }
        }

        public Int32 Right
        {
            get { return _margins.Right; }
            set
            {
                if (value == Right) return;
                OnPropertyChanging();
                _margins.Right = value;
                OnPropertyChanged();
            }
        }

        public Int32 Bottom
        {
            get { return _margins.Bottom; }
            set
            {
                if (value == Bottom) return;
                OnPropertyChanging();
                _margins.Bottom = value;
                OnPropertyChanged();
            }
        }

        #endregion

        /// <summary>
        ///     Initializes a new instance of the <see cref="MarginsViewModel" /> class.
        /// </summary>
        /// <param name="margins">Source margins.</param>
        public MarginsViewModel(IMargins margins)
        {
            _margins = margins;
        }
    }
}